const obj = {
  tag: require('./modules/tag'),
  user: require('./modules/user'),
  group: require('./modules/group'),
  tools: {
    // 根据值获取label
    matchLabel: function (mapping, val, labelKey = 'label') {
      for (const item in mapping) {
        if (String(mapping[item].value) === String(val)) {
          return mapping[item][labelKey]
        }
      }
      return '-'
    },
    transferOptions: (object) => {
      let options = []
      for (const o in object) {
        if (object[o].optionHidden) continue
        options.push(object[o])
      }
      return options
    },
    valueEqMapping: (mapping, val) => {
      if (typeof (mapping) === 'object') {
        return String(mapping.value) === String(val)
      }
      return String(mapping) === String(val)
    }
  }
}
window.Mapping = obj
export default obj
